/**
 * 
 */
package cn.edu.thsis.dao.impl;

import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

public class jdbcUtils {
	private static Properties props = null;
	static {
		//props初始化
		try {
			//加载配置文件
			InputStream in = jdbcUtils.class.getClassLoader().getResourceAsStream("dbconfig.properties");
			props = new Properties();
			props.load(in);
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
		//加载驱动类
				try {
					Class.forName(props.getProperty("driverClassName"));
				} catch (ClassNotFoundException e) {
					throw new RuntimeException(e);
				}
	}
	//获取连接
	public static Connection getConnection() throws SQLException {
		return DriverManager.getConnection(props.getProperty("url"),
				props.getProperty("username"),
				props.getProperty("password"));
	}
}
